package com.imagecollector.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imagecollector.common.R;
import com.imagecollector.domain.dto.RewardRecordSaveDTO;
import com.imagecollector.domain.dto.RewardRecordSearchDTO;
import com.imagecollector.domain.entity.TaskRewardRecord;
import com.imagecollector.service.ITaskRewardRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 任务打款记录表 前端控制器
 * </p>
 *
 * @author wrf
 * @since 2024-07-31
 */
@Api(tags = "打款相关功能接口")
@RestController
@RequestMapping("admin/taskRewardRecord")
public class TaskRewardRecordController {

    @Autowired
    ITaskRewardRecordService taskRewardRecordService;

    @ApiOperation("添加打款记录")
    @PostMapping("payForTask")
    public R payForTask(@RequestBody @Valid RewardRecordSaveDTO rewardRecordSaveDTO) {
        taskRewardRecordService.createRewardRecord(rewardRecordSaveDTO);
        return R.success().msg("记录成功");
    }

    @ApiOperation("打款列表查询")
    @PostMapping("paymentList")
    public R paymentList(@RequestBody RewardRecordSearchDTO rewardRecordSearchDTO) {
        Page<TaskRewardRecord> res = taskRewardRecordService.getPaymentList(rewardRecordSearchDTO);
        return R.success().data("data", res);
    }

    @ApiOperation("查询打款记录详情")
    @GetMapping("getRewardInfo")
    public R getRewardInfo(@RequestParam("id") @ApiParam("打款记录id") @NotNull Integer id) {
        TaskRewardRecord taskRewardRecord = taskRewardRecordService.getById(id);
        return R.success().data("data", taskRewardRecord);
    }

}
